import { useCallback, useEffect, useState, useRef } from "react";
import { message } from "antd";
import { queryDouYinPrintParam } from "@/services/common";
import { hiprint } from "vue-plugin-hiprint";
import {
	setPrinterName,
	getPrinterName,
	getCurrentUser,
	getExpressRelativePrinter,
	setExpressRelativePrinter
} from "@/utils/authority";
import Api from "@/pages/OrderModule/orderList/components/Actions/service";
import { cloneDeep, find, isEmpty, orderBy, groupBy } from "lodash";
import moment from "moment";

import {
	checkComponentsIsOpen,
	getAllPrinter,
	judgeHasWhichPlatform,
	print,
	kuaiXiaoPrintFunc,
	printVipShop
} from "@/utils/print.jsx";

// 唯一码模板接口
import request from "@/utils/request";
import { stringify } from "qs";
//快递批量打印 outboundNos
export async function batchPrintExpressByQualifiedOutbound(params) {
	return request(`/new-oms-ec/printTask/batchPrint`, {
		method: "Post",
		data: params
	});
	return request(`/new-wms/outboundorder/batch-print-by-express`, {
		method: "Post",
		data: params
	});
}
// 快递公司列表
export async function queryExpressList(params) {
	return request(`/blade-logistics/expresskxerp/expressKv?${stringify(params)}`);
}

//设置打印机名称
export async function savePrinterName(params) {
  return request(`/new-oms-ec/printTask/setPrinterNames`, {
    method: 'POST',
    data: params,
  });
}

const expressPlatform = {
	TAO_BAO: [1, "淘宝"],
	PIN_DUO_DUO: [2, "拼多多"],
	JING_DONG: [3, "京东"],
	JING_DONG_WJ: [4, "京东无界"],
	SHUN_FENG: [5, "顺丰"],
	JING_DONG_CLOUD: [6, "京东物流云"],
	WEI_PIN_HUI: [7, "唯品会JITX"],
	WEI_PIN_HUI_MP: [8, "唯品会MP"],
	KUAI_SHOU: [14, "快手"],
	DOU_YIN: [15, "抖音"],
	WX_SHI_PIN_HAO: [25, "微信视频号"],
	TAO_BAO_YFH: [26, "淘宝易发货"],
	JI_TU: [28, "极兔"],
	JING_DONG_YUN_CANG: [29, "京东云仓"],
	JING_DONG_YUN_CANG_DAI_FA: [30, "京东云仓代发"],
	DE_WU: [32, "得物"],
	DE_WU_ZHI_FA: [33, "得物直发"],
	XIAO_HONG_SHU: [40, "小红书"]
};
const expressPlatformList = Object.keys(expressPlatform).map(en => ({
	en: en,
	value: expressPlatform[en][0],
	name: expressPlatform[en][1]
}));
// const getLogisticsCompany = item => {
// 	const f = expressPlatformList.find(e => e.value == item.platform);
// 	return f?.name || "未找到快递公司";
// };

const formatPrintOrder = (val) => {
	const printArr = [];
	const arr = orderBy(val, 'printSequence');
	const list = groupBy(arr, 'warehouseId');
	for(let i in list) {
		console.log(i, list[i])
		const list1 = groupBy(list[i], 'printer');
		for(let j in list1) {
			const list2 = list1[j];
			list2.map((v, index) => {
				printArr.push({
					...v,
					num: index + 1,
					len: list2.length,
				})
			})
		}
	}
	return printArr;
}

let hiprintTemplate, runner;
//缓存多次提交打印数据的队列
const stagePrintData = [];

export const usePrintExpress = props => {
	const outboundNoKey = props?.outboundNo || "outboundNo";
	const expressCompanyKey = props?.expressCompanyKey || "expressCompany";
	const printerNameKey = props?.printerName || "printerName";
	const originSetName = getPrinterName();
	const [taskCount, setTaskCount] = useState(0);
	const [taskSuccessCount, setTaskSuccessCount] = useState(0);
	const [taskFailedCount, setTaskFallCount] = useState(0);
	const [taskSuccessList, setTaskSuccessList] = useState([]);
	const [taskFailedList, setTaskFailedList] = useState([]);
	const [errorPrintData, setErrorPrintData] = useState({}); //不能打印的
	const { handleCancel } = props || {};

	const printSuccessCallback = props.printSuccessCallback
		? props.printSuccessCallback
		: async params => {
				console.log("打印成功的记录更新 printSuccessCallback", params);
				await setTaskSuccessCount(taskSuccessCount + 1);
				await setTaskSuccessList([...taskSuccessList, params]);
				return new Promise((resolve, reject) => {
					resolve({});
				});
			};

	const printFailedCallback = props.printFailedCallback
		? props.printFailedCallback
		: async (res, list) => {
				console.log("打印失败的记录更新 printFailedCallback", res, list);
				await setTaskFallCount(taskFailedCount + 1);
				await setTaskSuccessList([...taskFailedList, list]);
				if (res?.printStatus?.length > 0) {
					message.warning(res.printStatus.map(e => `${e.documentID}打印失败:${e.detail}`).join(","));
				} else if (res?.results?.length > 0) {
					message.warning(res.results.map(e => ` ${e.taskID}打印${e.success ? "成功" : "失败"}:${e.failureReason}`).join(","));
				} else if (res.msg) {
					message.warning(`${list.orderSn}  ${res?.msg}`);
				} else {
					message.warning(list.orderSn + "打印失败");
				}
				return new Promise((resolve, reject) => {
					resolve({});
				});
			};

	const [selectedRows, setSelectedRows] = useState([]);
	const [expressData, setExpressData] = useState([]);
	const [expressList, setExpressList] = useState([]); //快递公司列表

	const [printerList, setPrinterList] = useState([]); //打印机列表
	const [currentPrintItem, setCurrentPrintItem] = useState([]);

	const [loading, setLoading] = useState(false);

	const logisticsCompanies = useRef([]);

	const updatePrinterName = async ({ logisticsCompany, printerName }) => {
		// console.log("设置打印机名称 updatePrinterName", logisticsCompany, printerName);
		const o = getExpressRelativePrinter() || {};

		o[logisticsCompany] = printerName;

		setExpressRelativePrinter(cloneDeep(o));

		setExpressData(pre => {
			const l = cloneDeep(pre);
			return l.map(e => {
				let p = e.logisticsCompany === logisticsCompany ? printerName || e.printerName : e.printerName;
				return {
					...e,
					printerName: p
				};
			});
		});

		return new Promise((resolve, reject) => {
			resolve({});
		});
	};
	useEffect(() => {
		// console.log("queryExpressList useEffect");
		getExpressList();
	}, []);
	async function getExpressList() {
		try {
			const res = await queryExpressList({ type: 0 });
			if (Array.isArray(res?.data)) {
				const d = res?.data.map(e => ({ name: e.baseExpressName, value: e.baseExpressId }));
				setExpressList(d);
				logisticsCompanies.current = d;
				// console.log("获取快递公司数据成功", d);
			} else {
				// console.warn("获取快递公司数据失败1", res);
				message.warning("获取快递公司数据失败");
			}
		} catch (error) {
			console.warn("获取快递公司数据失败2", error);
			message.warning("获取快递公司数据失败");
		}
	}
	async function awaitExpressList() {
		return new Promise((resolve, reject) => {
			const timer = setInterval(() => {
				if (Array.isArray(logisticsCompanies.current) && logisticsCompanies.current.length) {
					clearInterval(timer);
					resolve(logisticsCompanies.current);
				}
			}, 100);
		});
	}
	useEffect(() => {
		const count = taskSuccessCount + taskFailedCount;
		if (count === 0) return;
		// 判断成功加失败的数量是否 = 总数
		if (count === taskCount) {
			// 所有任务完成，执行打印结束总回调
			props.callback &&
				props.callback({
					successCount: taskSuccessCount,
					failedCount: taskFailedCount,
					taskCount: taskCount,
					successList: taskSuccessList,
					failedList: taskFailedList,
					...errorPrintData
				});
			setTaskCount(0);
			setTaskSuccessCount(0);
			setTaskFallCount(0);
			setTaskSuccessList([]);
			setTaskFailedList([]);
			setErrorPrintData({});
		}
	}, [taskSuccessCount, taskFailedCount]);

	const initPrinter = async rows => {
		// console.log("initPrinter", rows);
		setLoading(true);
		setTaskCount(rows.length); // 设置打印任务总数量
		setSelectedRows(cloneDeep(rows));
		if (!runner) {
			runner = new TaskRunner();
			runner.setConcurrency(1); // 同时执行数量
		}

		await awaitExpressList();

		return new Promise((resolve, reject) => {
			getAllPrinter(currentPrinters => {
				setLoading(false);
				setPrinterList(currentPrinters);

				resolve({ rows, currentPrinters });
			});
		});
	};
	const printExpress = (rows, printPageType, errorPrintData = {}) => {
		setTaskCount(rows.length); // 设置打印任务总数量
		initPrinter(rows).then(({ rows, currentPrinters }) => {
			getTemplate(rows, currentPrinters, __expressData => {
				doPrint(__expressData);
			}, printPageType, errorPrintData);
		});
	};

	const getUniqueListByKey = (arr, key, needKey) => {
		const result = [];
		const map = new Map();
		if (needKey) {
			arr.sort((a, b) => {
				if (a[needKey]) return -1;
				if (b[needKey]) return 1;
			});
		}

		for (const item of arr) {
			if (!map.has(item[key])) {
				map.set(item[key], true); // set any value to Map
				result.push(item);
			}
		}
		return result;
	};

	const [uniqueExpress, setUniqueExpress] = useState([]);
	useEffect(() => {
		// console.log("__expressData expressData", expressData);

		setUniqueExpress(getUniqueListByKey(expressData, "expressId"));
	}, [expressData]);
	//判断配置的打印机是否在线
	const judgePrinterIsOnline = name => {
		if (printerList.includes(name)) {
			return name;
		} else {
			return null;
		}
	};
	const judgePrinterConfig = configObj => {
		// const isSelect = [],
		// 	notSelect = [];
		// (Object.keys(configObj) || []).map(item => {
		// 	if (configObj[item]) {
		// 		isSelect.push(item);
		// 	} else {
		// 		notSelect.push(item);
		// 	}
		// });
		// if (notSelect.length) {
		// 	const newConfig = {};
		// 	// [...notSelect, ...isSelect].map(item => (newConfig[item] = configObj[item]));
		// 	// setConfigObj(newConfig);
		// 	return message.info(`检测到${notSelect.join("，")}未设置对应打印机，为了不影响快递打印，请设置对应快递的打印机`);
		// }
	};

	const handleReduceSubmit = num => {
		// console.log("handleReduceSubmit", num);
		const promise = new Promise(async resolve => {
			const list = currentPrintItem[num];
			// 判断是否存在打印数据
			if (
				list &&
				Object.prototype.toString.call(list.printData) === "[object Object]" &&
				Object.keys(list.printData).length === 0
			) {
				console.log(`系统单号 ${list.orderSn} 单没有打印数据，无法打印`, list);
				handleReduceSubmit(num + 1);
			} else {
				// console.log(props, "props");
				// console.log("handleReduceSubmit：", handleReduceSubmit);
				if (isEmpty(list)) {
					resolve();
					return;
				}
				kuaiXiaoPrintFunc(list, async res => {
					const { status, logPage = 22, printTaskId, orderSn } = res;
					await printSuccessCallback(list);
					if (status) {
						Api.printSuccessOp({
							logPage,
							printTaskId,
							systemNos: [orderSn]
						});
					} else {
						await printFailedCallback(res, list);
					}
					handleReduceSubmit(num + 1);
				});
				return;
				if (list.platform == 2 || list.platform == 28) {
					//拼多多
					const data = {
						ERPId: 303379400,
						cmd: "print",
						requestID: list.orderSn + "_T" + moment().valueOf(),
						task: {
							documents: [
								{
									contents: [JSON.parse(list.printData), { ...list.customData }],
									documentID: list.orderSn
								}
							],
							notifyType: ["print"],
							preview: false,
							previewType: "image",
							printer: list.printerName,
							taskID: list.orderSn + "_T" + moment().valueOf(),
							firstDocumentNumber: num + 1,
							totalDocumentCount: currentPrintItem.length
						},
						version: "1.0"
					};
					print(1, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else if (list.platform == 6 || list.platform == 29) {
					const printObj = JSON.parse(list.printData);
					const data = {
						orderType: "print",
						dataType: printObj?.dataType,
						parameters: {
							printName: list?.printerName,
							addData: printObj?.addData,
							tempUrl: printObj?.tempUrl,
							customTempUrl: list?.customData?.templateURL,
							customData: [list?.customData?.data],
							printData: [printObj?.data]
						}
					};
					print(6, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else if (list.platform == 7) {
					printVipShop(
						list.printData,
						async res => {
							if (res.status) {
								await printSuccessCallback(list);
								// len --;
							} else {
								await printFailedCallback(res, list);
							}
							handleReduceSubmit(num + 1);
						},
						list.printerName
					);
				} else if (list.platform == 8) {
					const printObj = JSON.parse(list.printData);
					const data = {
						actionType: "PRINT",
						traceId: +new Date(),
						storeId: printObj?.storeId,
						printerName: list?.printerName,
						printParamDTO: {
							templateUrl: printObj?.tempUrl,
							printDatas: [printObj],
							// "senderData": list.senderData,
							customData: list.customData
						}
					};
					print(8, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else if (list.platform == 14) {
					//快手
					const printObj = JSON.parse(list.printData);
					const data = {
						cmd: "print",
						requestID: list.orderSn + "_T" + moment().valueOf(),
						version: "1.0",
						task: {
							taskID: list.orderSn + "_T" + moment().valueOf(),
							preview: false,
							printer: list.printerName,
							previewType: "pdf",
							firstDocumentNumber: num + 1,
							totalDocumentCount: currentPrintItem.length,
							documents: [
								{
									documentID: list.orderSn,
									waybillCode: printObj.waybillCode,
									ksOrderFlag: printObj.ksOrderFlag || true,
									contents: [
										{
											addData: printObj?.addData,
											encryptedData: printObj?.printData,
											signature: printObj?.signature,
											key: printObj?.key,
											templateURL: printObj?.templateURL,
											ver: "waybill_print_secret_version_1"
										}
									]
								}
							]
						}
					};
					if (list?.customData?.templateURL) {
						data.task.documents[0].contents.push({
							customData: list?.customData?.data || {},
							templateURL: list?.customData?.templateURL
						});
					}
					print(14, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else if (list.platform == 15) {
					// 抖音
					const dyRes = await queryDouYinPrintParam({ orderCode: list.orderSn });
					const { success, data } = dyRes;
					let newData = {};
					newData.signature = JSON.parse(list.printData).sign;
					newData.templateURL = JSON.parse(list.printData).templateURL;
					newData.params = data;
					newData.encryptedData = JSON.parse(list.printData).print_data;
					newData.addData = JSON.parse(list.printData).addData;
					newData.customData = list.customData;
					newData.senderInfo = {
						address: {
							cityName: "",
							countryCode: "",
							detailAddress: "",
							districtName: "",
							provinceName: ""
						},
						contact: {
							mobile: "",
							name: ""
						}
					};
					if (success) {
						const data1 = {
							cmd: "print",
							requestID: list.orderSn + "_T" + moment().valueOf(),
							version: "1.0.1.8",
							task: {
								taskID: list.orderSn + "_T" + moment().valueOf(),
								firstDocumentNumber: num + 1,
								totalDocumentCount: currentPrintItem.length,
								preview: false,
								printer: list.printerName,
								previewType: "pdf",
								documents: [
									{
										documentID: list.orderSn,
										contents: [newData]
									}
								]
							}
						};
						print(15, data1, async res => {
							if (res.status) {
								await printSuccessCallback(list);
								// len --;
							} else {
								await printFailedCallback(res, list);
							}
							handleReduceSubmit(num + 1);
						});
					}
				} else if (list.platform == 25) {
					const printObj = JSON.parse(list.printData);
					const data = {
						command: "print",
						version: "2.0",
						requestID: list.orderSn + "_T" + moment().valueOf(),
						printer: list.printerName,
						taskList: [
							{
								taskID: list.orderSn + "_T" + moment().valueOf(),
								printInfo: printObj?.printData,
								printNum: {
									curNum: num + 1,
									sumNum: currentPrintItem.length
								},
								customInfo: { templateUrl: list?.customData?.templateURL, data: list?.customData?.data },
								extendData: { ...printObj?.addData }
							}
						]
					};
					print(25, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else if (list.platform == 33) {
					//得物
					const printObj = JSON.parse(list.printData);
					const data = {
						cmd: "print",
						version: "2.2.1",
						requestID: list.orderSn + "_T" + moment().valueOf(),
						task: {
							isvName: "isvName", // ISV 名称
							taskID: list.orderSn + "_T" + moment().valueOf(),
							printer: list.printerName,
							firstDocumentNumber: num + 1,
							totalDocumentCount: currentPrintItem.length,
							documents: [
								{
									printData: { ...printObj, customContent: undefined },
									customContent: printObj?.customContent
								}
							]
						}
					};
					print(33, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else if (list.platform == 40) {
					//小红书
					const data = {
						cmd: "print",
						requestID: list.orderSn + "_T" + moment().valueOf(),
						version: "1.0",
						task: {
							taskID: list.orderSn + "_T" + moment().valueOf(),
							preview: false,
							printer: list.printerName,
							previewType: "pdf",
							firstDocumentNumber: num + 1,
							totalDocumentCount: currentPrintItem.length,
							documents: [
								{
									documentID: list.orderSn,
									contents: [JSON.parse(list.printData), { ...list.customData }]
								}
							]
						}
					};
					print(40, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				} else {
					let data;
					if (list.platform == 5) {
						//顺丰
						data = {
							cmd: "print",
							requestID: list.orderSn + "_T" + moment().valueOf(),
							version: "1.0",
							task: {
								taskID: list.orderSn + "_T" + moment().valueOf(),
								preview: false,
								printer: list.printerName,
								previewType: "pdf",
								firstDocumentNumber: num + 1,
								totalDocumentCount: currentPrintItem.length,
								documents: [
									{
										documentID: list.orderSn,
										contents: [JSON.parse(list.printData)]
									}
								]
							}
						};
					} else {
						data = {
							cmd: "print",
							requestID: list.orderSn + "_T" + moment().valueOf(),
							version: "1.0",
							task: {
								taskID: list.orderSn + "_T" + moment().valueOf(),
								preview: false,
								printer: list.printerName,
								previewType: "pdf",
								firstDocumentNumber: num + 1,
								totalDocumentCount: currentPrintItem.length,
								documents: [
									{
										documentID: list.orderSn,
										contents: [JSON.parse(list.printData), { ...list.customData }]
									}
								]
							}
						};
						// console.log("打印前", data);
					}
					print(2, data, async res => {
						if (res.status) {
							await printSuccessCallback(list);
							// len --;
						} else {
							await printFailedCallback(res, list);
						}
						handleReduceSubmit(num + 1);
					});
				}
			}
		});

		promise.then(() => {
			if (stagePrintData.length) {
				setCurrentPrintItem(stagePrintData[0]);
				stagePrintData.splice(0, 1);
			} else {
				setCurrentPrintItem([]);
				handleCancel && handleCancel();
			}
		});
	};

	useEffect(() => {
		// console.log("正在打印批次：1=", currentPrintItem);
		if (currentPrintItem.length) {
			// expressData.length && setCurrentGetData([]);
			handleReduceSubmit(0);
			// console.log("正在打印批次：2=", currentPrintItem);
		}
	}, [currentPrintItem]);

	const getTemplate = (rows, currentPrinters, callback, printPageType, errorPrintData) => {
		setLoading(true);
		currentPrinters = currentPrinters || printerList;
		rows = rows || selectedRows;

		const param = rows.map(e => (typeof e === "string" || typeof e === "number" ? e : e[outboundNoKey]));

		const newConfig = {};
		// 获取面单模版
		batchPrintExpressByQualifiedOutbound({ systemNos: rows, printPageType }).then(({ success, data, code }) => {
			// console.log(success, data, code);
			setLoading(false);
			if (success && data?.length) {
				// console.log("batchPrintExpressByQualifiedOutbound", data);
				const printerConfigs = getExpressRelativePrinter() || {};

				const __expressData = [];
				const arr = [];
				data.map(store => {
					store.items.map(item => {
						const f = logisticsCompanies.current.find(e => e.value == item.expressId);
						const __logisticsCompany = f ? f.name : item.expressId;

						const logisticsCompany = item.expressName || __logisticsCompany;
						// 获取对应打印机
						const printerName = item.printerName || printerConfigs[logisticsCompany];
						arr.push({
							printerName,
							taskId: item.printTaskId,
						})
						//保存打印机名
						savePrinterName(arr);
						item.printLogisticsList.map(child => {
							__expressData.push({
								...child,
								printTaskId: item.printTaskId,
								printer: printerName
							});
						});
					});
					// console.log(item);
					// 获取快递公司名称
					// const f = logisticsCompanies.current.find(e => e.value == item.expressId);
					// const __logisticsCompany = f ? f.name : item.expressId;

					// const logisticsCompany = item.logisticsCompany || __logisticsCompany;
					// // 获取对应打印机
					// const printerName = item.printerName || printerConfigs[logisticsCompany];
					// // console.log("------获取对应打印机-------");
					// // console.log("__expressData item", item, item.printName);
					// // console.log("printerConfigs & logisticsCompany", printerConfigs, logisticsCompany);
					// // console.log("printerConfigs.printName", printerConfigs[logisticsCompany]);

					// const uuid = item.orderSn + Math.random();

					// newConfig[logisticsCompany] = currentPrinters
					// 	? judgePrinterIsOnline(currentPrinters[logisticsCompany])
					// 	: judgePrinterIsOnline(originSetName);
					// return {
					// 	...item,
					// 	id: uuid,
					// 	uuid: uuid,
					// 	taskId: uuid,
					// 	logisticsCompany,
					// 	printerName
					// };
				});
				const formatArr = formatPrintOrder(cloneDeep(__expressData));
				setExpressData(formatArr);

				setErrorPrintData(errorPrintData)
				callback && callback(formatArr);
			} else {
				message.warning("没有可打印的快递面单");
				props.callback &&
				props.callback(errorPrintData);
			}
		});
	};

	const doPrint = __expressData => {
		// console.log("doPrint", __expressData);
		setLoading(true);
		checkComponentsIsOpen(judgeHasWhichPlatform(cloneDeep(__expressData)), res => {
			if (res.status) {
				//锁定打印机 任务id
				let getNums = 0;
				const postParams = []; //更新打印机名称（打印批次）
				cloneDeep(__expressData).map((item, index) => {
					// console.log("__expressData.map((item", item);

					getNums++;
					const printGroup = [{ ...item }];

					// console.log("锁定打印机", index, currentPrintItem);

					if (!index && !currentPrintItem.length) {
						// console.log("锁定打印机 setCurrentPrintItem", printGroup);

						setCurrentPrintItem(cloneDeep(printGroup));
					} else {
						stagePrintData.push(printGroup);
					}
				});

				// Modal.success({
				// 	content: isAllPackages
				// 		? `面单打印完成,总计${useCheckedarr.length}个,成功${getNums}个,失败${useCheckedarr.length - getNums}个`
				// 		: `面单打印完成,总计${ids.length}个,成功${getNums}个,失败${ids.length - getNums}个`,
				// 	onOk: () => {
				// 		onOk();
				// 	}
				// });
			}
			setLoading(false);
		});
	};
	return {
		printExpress, // 一步打印

		// 分步打印 \views\StockManage\Outbound\component\Actions\ExpressPrintModal
		initPrinter, //初始化打印机
		getTemplate, //获取打印模板
		doPrint, //执行打印
		printerList, //当前可用的打印机
		expressData, //要打印的数据
		uniqueExpress, //快递公司不重复的打印数据列表，用于展示 expressCompany => printer 的关联关系
		loading, // 刷新
		expressList, //快递公司列表
		getExpressRelativePrinter,
		updatePrinterName // 更新快递公司关联的打印机
	};
};
